//
//  HTResponse.swift
//  MagaCore
//
//  Created by MrMessy on 2023/5/12.
//

import Foundation
import HandyJSON

struct HTResponse: HandyJSON {
  var var_data: Any?
  var var_status: String?
  var var_message: String?
	var var_list: Any?

  mutating func mapping(mapper: HelpingMapper) {
    mapper <<<
      self.var_data <-- "data"
    mapper <<<
      self.var_status <-- "status"
    mapper <<<
      self.var_message <-- "msg"
		mapper <<<
			self.var_list <-- "list"
  }

  func ht_dataDist() -> [String: Any]? {
    let params = toJSON()
    let var_data = params!["data"] ?? ["": ""]
    return var_data as? [String : Any]
  }

  func ht_data() -> String? {
    let params = toJSON()
    let var_data = params!["data"] ?? ["": ""]
    do {
      let jsonData: Data
      jsonData = try JSONSerialization.data(withJSONObject: var_data, options: [])
      return String(data: jsonData, encoding: .utf8)
    } catch _ {
      return nil
    }
  }
	
	func ht_list() -> String? {
		let params = toJSON()
		let var_data = params!["list"] ?? ["": ""]
		do {
			let jsonData: Data
			jsonData = try JSONSerialization.data(withJSONObject: var_data, options: [])
			return String(data: jsonData, encoding: .utf8)
		} catch _ {
			return nil
		}
	}
}
